<!--
 * @description  :航空运输档案维护详情
 * @descriptionDetail:航空运输档案维护详情
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-16 13:18:15
-->
<template>
  <view :class="!isCom() ? 'page' : ''">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar title="航空运输档案维护" v-if="!isCom()">
    </theme-navbar>
    <!-- #endif -->
    <view class="content content-bg ifn-content" style="background-color: white">
      <u-form
        class="u-form-m"
        :label-style="labelStyle"
        :model="baseInfo"
        :error-type="['border-bottom', 'message',]"
        label-width="auto"
        label-position="top"
        ref="uForm"
      >
        <u-form-item label="班次名称">
          <u-input
            v-model="baseInfo.serviceName"
            :disabled="true"
            placeholder=""
          ></u-input>
        </u-form-item>
        <u-form-item label="登记单位">
          <u-input
            v-model="baseInfo.orgName"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
        <u-form-item label="所属航空公司">
          <u-input
            v-model="baseInfo.planeName"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
        <u-form-item label="始发时间">
          <u-input
            v-model="baseInfo.startTime"
            placeholder=""
            :disabled="true"
          >
          </u-input>
        </u-form-item>
        <u-form-item label="始发站">
          <u-input
            v-model="baseInfo.startStation"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
        <u-form-item label="案发地">
          <u-input
            v-model="baseInfo.caseStation"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
        <u-form-item label="途径站点">
          <u-input
            v-model="baseInfo.pathWayStation"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
        <u-form-item label="终点">
          <u-input
            v-model="baseInfo.endStation"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
        <u-form-item label="始发时间">
          <u-input
            v-model="baseInfo.service"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
        <u-form-item label="是否伪装">
          <u-input
            v-model="baseInfo.pretendName"
            :disabled="true"
            placeholder=""
          >
          </u-input>
        </u-form-item>
      </u-form>
    </view>
    <view class="content u-page">
      <u-gap :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
      <fsection :title="title.images" :customStyle="customStyle"></fsection>
      <view class="u-form-m pl-10">
        <m-upload
          maxCount="99"
          :file-list="imgList"
          :disabled="true"
          :deletable="false"
          upApiUrl="uploadBase64File"
          :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.k_transport_attr}"
        >
        </m-upload>
        <u-image
          width="100%"
          v-if="!imgList.length"
          height="330rpx"
          style="padding:0 0 34rpx 14rpx"
          mode="scaleToFill"
          :src="'/static/certificate/noImg.png'"
        >
        </u-image>
      </view>
    </view>
    <view class="u-form">
      <u-gap :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
      <fsection :title="title.connect" :customStyle="customStyle"></fsection>
      <list-view
        :i="0"
        :index="0"
        :load-data="loadCase"
        :init-load="false"
        :noMoreDataTipShow="false"
        height="300px"
        ref="mescrollItem0"
        class="specailListview"
      >
        <template slot-scope="d">
          <caseConnection :connection="d.data" class="case-sty"></caseConnection>
        </template>
      </list-view>
    </view>
  </view>
</template>

<script>
import fsection from "@/components/form-section.vue";
import mUpload from "@/components/m-upload.vue";
import caseConnection from '../components/caseConnection.vue';
import certificateService from "@/service/certificate/certificate.service.js";
import listView from '@/components/list_view.vue';
import intelligenceservice from "@/service/intelligence/intelligence.service";
export default {
  components: {
    fsection,mUpload,caseConnection,listView,
  },
  props:{
    record:{
      type:Object,
      default:() => { return undefined; },
    },
  },
  data() {
    return {
      customStyle:{
        padding:"20rpx 32rpx",
      },
      baseInfo: {
        endStation: "",
        getPlaceCount: "",
        historyUuid: "",
        menuCode: null,
        orgUuid: "",
        pathWayStation: "",
        planeName: "",
        pretend: "",
        pretendName:"",
        service: "",
        serviceName: "",
        startStation: "",
        status: "",
        statusName:"",
      },
      labelStyle: {
        fontWeight: 400,
        color: this.$theme.u_main_color,
        fontSize: '.75rem',
      },
      title:{
        images:"图片信息",
        connectMsg:"航空详情",
        connect:"案件关联",
      },
      casedata:[],
      imgList:[],
    }
  },
  onReady() {
    this.$refs.uForm.setRules(this.rules);
    this.getListViewTop();
  },
  watch: {
    record:{
      handler(newVal,oldVal){
        if(!newVal) return;
        this.loadData();
        this.initAuditImage();
      },
      immediate: false,
      deep: true,
    },
  },
  created(){
    this.loadData();
    this.initAuditImage();
  },
  methods: {
    getListViewTop(){
      this.$u.getRect('.case-search-lay').then(res => {
        this.listViewTop = (this.$u.sys().statusBarHeight + res.top + res.height) + 'px';
      });
      this.$u.getRect('.submit-btns').then(res => {
        this.bottomOffset = (this.$u.sys().screenHeight - res.top) + "px";
      });
    },
    loadCase(page){
      return new Promise((resolve,reject) => {
        let params = {
          page:page.num,
          limit:page.size,
          paras:{
            archiveUuid:this.baseInfo.uniqueKey,
            type: "plane-case",
          },
        }
        intelligenceservice.archiveCaseList(params).then(res => {
          if(res.success){
            resolve({ data: {list: res.data, totalCount : res.count,},});
          }else{
            this.$modal.alert(res.msg);
            resolve({ data: {list: [], totalCount : 0,},});
          }
        }).catch(e => {
          this.$u.toast('请求失败:' + e);
          resolve({
            count: 0,
            data:[],
          });
        });
      })
    },
    initAuditImage(){
      certificateService.goFiles(this.baseInfo.uuid,this.$FILE_GROUP_TYPE.k_transport_attr).then(res => {
        if(res.success) this.imgList = res.data;
      }).catch(e => {
        console.log(e);
      })
    },
    loadData(){
      if(this.record){
        this.baseInfo = this.record;
      }else{
        this.baseInfo = this.getRouteParam();
      }
    },
    // 是组件
    isCom(){
      return this.record;
    },
  },
}
</script>

<style scoped lang="scss">
@import "./add.scss";
.page{
  padding: 0;
}
</style>
